Cursor#16
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||||
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||||||||||
PR Type
Enhancement, Bug fix
Description
Logging refactor and WebSocket integration: Replaced custom
ColoredFormatterwith standard logging and implementedWebSocketLogHandlerto stream logs to frontend in real-time with ANSI color supportPosition tracking improvements: Added
opened_atISO timestamp for countdown timers, implemented fixed-distance trailing stop (_update_trailing_stop_fixe()), and enhanced break-even trigger logic using newbreak_even_triggerconfiguration parameterSlippage calculation enhancements: Improved slippage tracking with detailed logging, proper USDT conversion, and comprehensive analytics integration in
close_position()Position type handling fixes: Enhanced
position_check_loop_callback()to properly handle string, dict, and object Position types with error handlingAPI response restructuring: Enhanced
api_get_sessions_stats_global()with nestedglobal_statsobject and exposed Telegram notification configuration with individual type togglesTelegram configuration management: Implemented
update_telegram_configandtest_telegramcommands for dynamic settings management with 9 notification type controlsConfiguration parameter additions: Added
break_even_trigger,trailing_distance, anduse_slippage_calculationparameters with proper validation and dynamic updatesTP/SL mode enhancements: Fixed
tp_sl_modehandling to acceptESCALIERmode alongside existing modes with properuse_atrflag updatesFrontend UI improvements: Implemented global error popup with auto-hide, debug mode toggle with element inspection, dynamic bot phase tracking, and debounced TP/SL mode selector
Log viewer enhancements: Added ANSI color parsing, emoji extraction, and XLSX export functionality with styled headers
Position card redesign: Added dynamic duration countdown, intelligent TP/SL level calculation supporting FIXE/ESCALIER/ATR modes, and real-time trading config integration
Data consistency fixes: Fixed scalability data field mappings (
spread,bookDepth,balanceScore), trade duration field consistency, and PnL calculations in trade historyExport functionality expansion: Migrated to Excel (XLSX) format with improved formatting and added new setup analysis export with 5 sheets (Trades, Configuration, TP-SL, Thresholds, Patterns)
Orderbook null-safety: Added null-safety checks and array bounds validation to prevent crashes when orderbook data is unavailable
Debug mode infrastructure: Added comprehensive
data-debug-nameattributes throughout frontend components for element inspection and testingDiagram Walkthrough
File Walkthrough
19 files
main.py
Logging refactor, WebSocket integration, position handling fixesmain.py
ColoredFormatterclass and replacing with standard
logging.basicConfig()WebSocketLogHandlerintegration to send logs to frontend viaWebSocket in
init_instances()position_check_loop_callback()tohandle string, dict, and object Position types with proper error
handling
api_get_sessions_stats_global()endpoint to restructureresponse format with
global_statsnested object and removed redundantPnL fields
and WebSocket state with individual notification type toggles
update_telegram_configandtest_telegramcommands fordynamic Telegram settings management
break_even_triggerandtrailing_distanceconfigurationparameters with proper validation and logging
tp_sl_modehandling to acceptESCALIERmode alongside existingmodes with proper
use_atrflag updatesuse_slippage_calculationconfiguration parameter with dynamicupdates to both
position_configandposition_managerlogger.py
WebSocket log handler implementation for frontendutils/logger.py
WebSocketLogHandlerclass to capture logs and emitthem to frontend via WebSocket
WebSocketLogHandlerwith properlevel-based coloring (DEBUG, INFO, WARNING, ERROR, CRITICAL)
setup_logger()function to accept optionalws_managerparameter for WebSocket integration
formatting for frontend display
position_check_loop.py
Position update events and stats calculation enhancementscore/callbacks/position_check_loop.py
opened_atISO timestamp to position update events for frontendcountdown timer functionality
values from analytics database
total_pnl_usdtandtotal_pnl_pctto 4decimal places to preserve small values
net_pnl_usdtfield foraccurate performance metrics
analyzer.py
Orderbook rejection logging and WebSocket integrationcore/analyzer.py
critical notifications
proper async handling and fallback error management
blocking analyzer execution
+page.svelte
Global error popup, debug mode, bot phase trackingfrontend/src/routes/+page.svelte
5-second auto-hide functionality
data-debug-nameattributes forelement inspection
prevent excessive config updates
position_active,scan_setups,scan_scalability, andarrêtstatesPnLPercentChartcomponent alongside existingPnLChartforpercentage-based analytics
(ConnectionStatus left, debug toggle right)
and phase transitions
tracking
LogViewer.svelte
Log viewer ANSI parsing and XLSX export enhancementfrontend/src/lib/components/LogViewer.svelte
+page.sveltefor global displayacross all pages
coloring while preserving message text
all emoji types
and configurable column widths
[HH:MM:SS] LEVEL - messageformat with proper color application
formatTime()to recognize and preserve pre-formatted HH:MM:SStimestamps
log-detailfield support for additional log information displaySessionSelector.svelte
Debug mode attribute additionsfrontend/src/lib/components/SessionSelector.svelte
data-debug-nameattributes throughout componentfor debug mode element inspection
debug traceability
WinLossChart.svelte
Debug mode attribute additionsfrontend/src/lib/components/WinLossChart.svelte
data-debug-nameattributes to all major DOM elements for debugmode support
functionality
VariablesPanel.svelte
Add break-even and trailing stop parameters with debug attributesfrontend/src/lib/components/VariablesPanel.svelte
break_even_triggerandtrailing_distanceto default config with values 0.3 and 0.15simplified tab change detection logic
!completeConfiginstead of trackingpreviousSubTabstatedata-debug-nameattributes throughout the template fordebugging/testing purposes
break_even_triggerandtrailing_distanceparameters in FIXE mode section
break_even_triggerandtrailing_distanceand refresh completeConfigwhen on current tab
ExportPanel.svelte
Add setup analysis export option with debug attributesfrontend/src/lib/components/ExportPanel.svelte
exportSetupAnalysisfunction from export utilitiesanalysis export functionality
with description mentioning .xlsx format
data-debug-nameattributes to all UI elements fordebugging/testing
BotControls.svelte
Implement dynamic bot status messaging with phase trackingfrontend/src/lib/components/BotControls.svelte
botPhasestore andgetPhaseMessagefunction for dynamicstatus messaging
activePositionstore to track active trading positionsstatusMessagethat prioritizes position active status,bot phase, scanner state, and fallback to stopped state
statusMessagevariable
data-debug-nameattributes to all UI elements fordebugging/testing
Tabs.svelte
Add debug attributes to tab component elementsfrontend/src/lib/components/Tabs.svelte
data-debug-nameattributes to tab container, header, buttons,icons, and labels for debugging/testing
tab element
PositionCard.svelte
Dynamic position tracking with intelligent TP/SL calculationfrontend/src/lib/components/PositionCard.svelte
second
TP/SL levels
with intelligent level calculation
instead of escalier levels grid
data-debug-name) throughouttemplate for testing
sections
NotificationSettings.svelte
Telegram notification settings with granular type controlsfrontend/src/lib/components/NotificationSettings.svelte
toggles
loadTelegramConfig()to fetch Telegram settings frombackend via WebSocket
saveTelegramConfig()andtestTelegram()functions for managingTelegram notifications
when disabled
synchronization
SettingsPanel.svelte
Simplified settings panel to frontend-only configurationfrontend/src/lib/components/SettingsPanel.svelte
(sl_percent, tp_percent, trailing_trigger_pnl)
loadBackendConfig()andsyncWithBackend()functionsPnLPercentChart.svelte
New cumulative PnL percentage visualization chartfrontend/src/lib/components/PnLPercentChart.svelte
StatsPanel.svelte
Enhanced stats display with percentage metrics and debug attributesfrontend/src/lib/components/StatsPanel.svelte
data-debug-nameattributes to all stat boxes and valuesScannerPanel.svelte
Improved scanner panel layout and added debug attributesfrontend/src/lib/components/ScannerPanel.svelte
data-debug-nameattributes to all pair cards and metricsresponsiveness
export.js
Enhanced export functionality with Excel format and setup analysisfrontend/src/lib/utils/export.js
readability
exportSetupAnalysis()function exporting 5 sheets(Trades, Configuration, TP-SL, Thresholds, Patterns)
4 files
position_manager.py
Trailing stop refactor, slippage calculation improvementscore/position_manager.py
opened_atISO timestamp field toPosition.to_dict()for frontendcountdown timer support
_update_trailing_stop_fixe()method for fixed-distancetrailing stop in FIXE mode
check_position()to usebreak_even_triggerfromTRADING_CONFIGfor first partial TP trigger thresholdor when PnL exceeds
break_even_triggerconversion from percentage
close_position()to calculatenet_pnl_pctaccounting fortotal costs (fees + slippage)
percentage and USDT values
_estimate_slippage()logging to use INFO level for visibilityand added validation for invalid spread/depth values
scanner_loop.py
Scalability data field name correctionscore/callbacks/scanner_loop.py
output (
spread,bookDepth,balanceScore,bidVol,askVol)propagation
spread_pct←spread,depth←bookDepth,balance←balanceScoreanalytics_database.py
Trade duration field consistency fixcore/analytics_database.py
get_trades()to ensureduration_secondsfieldis present when
durationexistsdurationtoduration_secondsif neededTradeHistory.svelte
Fixed PnL calculations and improved data format handlingfrontend/src/lib/components/TradeHistory.svelte
sessionPnLcalculation to usenet_pnl_usdtdirectly (includesslippage/fees)
sessionPnLPctto return total instead of average percentageformats
percentage
4 files
GlobalStats.svelte
Added debug attributes for testing and debuggingfrontend/src/lib/components/GlobalStats.svelte
data-debug-nameattributes to all stat cards and contentsections
VolumeChart.svelte
Added debug attributes to volume chart componentfrontend/src/lib/components/VolumeChart.svelte
data-debug-nameattributes to chart container, header, andcontrols
PnLChart.svelte
Added debug attributes to PnL chart componentfrontend/src/lib/components/PnLChart.svelte
data-debug-nameattributes to chart container, header, andwrapper
ConnectionStatus.svelte
Added debug attributes to connection status componentfrontend/src/lib/components/ConnectionStatus.svelte
data-debug-nameattributes to connection status elements7 files